import upload from '@/utils/upload'
import request from '@/utils/request'

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
	const data = {
		oldPassword,
		newPassword
	}
	return request({
		url: '/system/user/profile/updatePwd',
		method: 'put',
		params: data
	})
}

// 查询用户个人信息
export function getUserProfile() {
	return request({
		url: '/system/user/profile',
		method: 'get'
	})
}
// 查询订单分布情况
export function getOrderNum() {
	return request({
		url: '/workorder/workInfo/getOrderNum',
		method: 'get'
	})
}
// 查询工单分类
export function getWorkclass() {
	return request({
		url: '/workorder/workclass/list',
		method: 'get'
	})
}
// 添加巡查点信息
export function addTaskPoint(data) {
	return request({
		url: '/inspection/detail',
		method: 'put',
		data: data
	})
}
// 二维码扫码查询巡检点信息
export function getPointInfo(pointNum) {
	return request({
		url: '/inspection/points/info/' + pointNum,
		method: 'get',
	})
}
// 查询巡检路线
export function getRouteList(pageNum, pageSize, id) {
	const data = {
		pageNum,
		pageSize,
		id,
	}
	return request({
		url: '/inspection/route/listAll',
		method: 'get',
		params: data
	})
}
// 查询成员信息
export function getTeamMember(pageNum, pageSize, teamId) {
	const data = {
		pageNum,
		pageSize,
		teamId,
	}
	return request({
		url: '/system/role/authUser/allocatedTeamList',
		method: 'get',
		params: data
	})
}
// 查询巡检任务列表
export function getInspectionOrderList() {
	return request({
		url: '/Inspection/inspectionOrder/list',
		method: 'get'
	})
}
// 查询巡检计划列表
export function getInspectionList() {
	return request({
		url: '/inspection/plan/list',
		method: 'get'
	})
}
// 查询巡查任务详情
export function getInspectTask(id) {
	return request({
		url: '/Inspection/inspectionOrder/Task/' + id,
		method: 'get'
	})
}
// 删除巡检计划列表 id
export function delInspectionList(planId) {
	return request({
		url: '/inspection/plan/' + planId,
		method: 'delete'
	})
}

// 查询保养计划
export function getMaintenanceList() {
	return request({
		url: '/maintenance/plan/listInfo',
		method: 'get'
	})
}
// 查询自己相关保养任务
export function getMaintenanceTaskUser() {
	return request({
		// url: '/maintenance/maintenance/TaskUser',
		url: '/maintenance/maintenance/list',
		method: 'get'
	})
}
// 查询保养任务详情
export function getMaintenanceTask(id) {
	return request({
		url: '/maintenance/maintenance/Task/' + id,
		method: 'get'
	})
}
// 修改保养任务详情
export function putMaintenanceDetail(data) {
	return request({
		url: '/maintenance/detail',
		method: 'put',
		data:data
	})
}
// 查询保养任务标准详情
export function getMaintenanceRelationship(id) {
	return request({
		url: '/maintenanceCheck/relationship/' + id,
		method: 'get'
	})
}
// 查询设备信息 id
export function getdeviceInfo(id) {
	return request({
		url: '/device/deviceInfo/' + id,
		method: 'get'
	})
}
// 查询设备信息 code
export function getdeviceInfoCode(code) {
	return request({
		url: '/device/deviceInfo/getQrInfo/' + code,
		method: 'get'
	})
}
// 查询个人常用地址管理列表 userid
export function getAddressList(userid) {
	return request({
		url: '/system/address/list/' + userid,
		method: 'get'
	})
}
// 查询个人常用地址管理列表 id
export function delAddressList(id) {
	return request({
		url: '/system/address/' + id,
		method: 'delete'
	})
}

// 新增我的地址
export function addAddress(data) {
	return request({
		url: '/system/address',
		method: 'post',
		data: data
	})
}
// 新增我的地址
export function editorAddress(data) {
	return request({
		url: '/system/address',
		method: 'put',
		data: data
	})
}
// 新增我的工单
export function getMyworkInfo(data) {
	return request({
		url: '/workorder/MyworkInfo',
		method: 'post',
		data: data
	})
}
// 修改我的工单
export function editorMyworkInfo(data) {
	return request({
		url: '/workorder/MyworkInfo',
		method: 'put',
		data: data
	})
}
// 撤销我的工单
export function delMyworkInfo(id) {
	return request({
		url: '/workorder/MyworkInfo/' + id,
		method: 'delete',
	})
}
// 新增常用语
export function addLanguages(data) {
	return request({
		url: '/system/languages',
		method: 'post',
		data: data
	})
}
// 修改常用语
export function ediotrLanguages(data) {
	return request({
		url: '/system/languages',
		method: 'put',
		data: data
	})
}
// 修改工单serviceId
export function ediotrWordershare(data) {
	return request({
		url: '/workorder/workInfo/share',
		method: 'put',
		data: data
	})
}
//查询对应用户的常用语
export function getLanguages(userid) {
	return request({
		url: '/system/languages/list/' + userid,
		method: 'get',
		// params: userid
	})
}
//查询用户信息
export function getallPeople(deptId) {
	return request({
		url: '/workorder/workInfo/allPeople/' + deptId,
		method: 'get',
	})
}
//删除常用语
export function delLanguages(id) {
	return request({
		url: '/system/languages/' + id,
		method: 'delete',
	})
}
//根据orderNum订单号查询所有工单操作记录
export function getOrderInfoList(orderNum) {
	return request({
		url: '/workorder/workrecods/getOrderInfoList/' + orderNum,
		method: 'get',
	})
}
// 评论工单
export function Orederevaluate(data) {
	return request({
		url: '/workorder/MyworkInfo/evaluate',
		method: 'post',
		data: data
	})
}
// 修改用户个人信息
export function updateUserProfile(data) {
	return request({
		url: '/system/user/profile',
		method: 'put',
		data: data
	})
}
// 修改待办状态
export function updateState(data) {
	return request({
		url: '/workorder/myworktodo/updatestate',
		method: 'put',
		data: data
	})
}
// 修改维修内容
export function updateService(data) {
	return request({
		url: '/workorder/myworktodo',
		method: 'put',
		data: data
	})
}
// 查看维修内容
export function getService(id) {
	return request({
		url: '/workorder/myworktodo/' + id,
		method: 'get',
	})
}
// 查询用户报单  传页数、数量、userid
export function getWorkList(pageNum, pageSize, state, params) {
	const data = {
		pageNum,
		pageSize,
		state,
		params
	}
	// console.log("data", data);
	return request({
		url: '/workorder/workInfo/list',
		method: 'get',
		params: data
	})
}
// 查询用户报单  传页数、数量、userid
export function MyCustoms(pageNum, pageSize, userId, state, params) {
	const data = {
		pageNum,
		pageSize,
		userId,
		state,
		params
	}
	return request({
		url: '/workorder/MyworkInfo/list',
		method: 'get',
		params: data
	})
}
// 查询待办列表  state、serviceId
export function myWorktodo(state, serviceId) {
	const data = {
		state,
		serviceId
	}
	return request({
		url: '/workorder/myworktodo/list',
		method: 'get',
		params: data
	})
}
// 查询楼栋信息  deptId
export function getDeptCascade(deptId) {
	const data = {
		deptId
	}
	return request({
		url: '/build/buildInfo/DeptCascade',
		method: 'get',
		params: data
	})
}

// 用户头像上传
export function uploadAvatar(data) {
	return upload({
		url: '/system/user/profile/avatar',
		name: data.name,
		filePath: data.filePath
	})
}

//上传文件
export function uploadFile(data) {
	return upload({
		url: '/common/upload',
		// name: data.name,
		filePath: data
	})
}
//查看所有设备信息
export function getDeviceInfoAll() {
	return request({
		url: '/device/deviceInfo/getDeviceList',
		method: 'get',
	})
}

//根据设备id查询保养内容详情
export function getDevicemaintenanceInfoById(id) {
	return request({
		url: '/maintenance/detail/deviceInfo/' + id,
		method: 'get',
	})
}
//催办工单
export function remindOrder(id) {
	return request({
		url: '/workorder/workInfo/remind/' + id,
		method: 'get',
	})
}
//查看个人通知栏列表
export function getNoticeList(pageNum, pageSize) {
	const data = {
		pageNum,
		pageSize,
	}
	return request({
		url: '/system/notice/listAll',
		method: 'get',
		params: data
	})
}
//获取通知栏详情
export function getNoticeById(noticeId) {
	return request({
		url: '/system/notice/' + noticeId,
		method: 'get',
	})
}
// 修改公告
export function updateStateNotice(userId,noticeId) {
  const data = {
    userId,
    noticeId
  }
  return request({
    url: '/system/notice/updateState',
    method: 'put',
    data: data
  })
}
